package view.rules;

import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;

import net.miginfocom.swing.MigLayout;

public class StemPanel extends JPanel{
	
	private JPanel upperPanel;
	public JRadioButton stemDnChange;
	public JRadioButton stemDoChange;
	public JCheckBox redupChekBox;
	private JLabel redupLabel;
	private JPanel lowerPanel;
	private JRadioButton phoneRButton;
	private JRadioButton alphaRButton;
	private ButtonGroup buttonGroup1;
	private ButtonGroup buttonGroup2;
	
	public StemPanel(){
		this.setLayout(new MigLayout());
		this.setBorder(BorderFactory.createTitledBorder("Stem"));
		
		initComponent();
		addComponent();
	}

	private void initComponent() {
		
		upperPanel = new JPanel();
		upperPanel.setLayout(new MigLayout());
		
		stemDnChange = new JRadioButton("Stem doesn't Change");
		stemDoChange = new JRadioButton("Stem Changes");
		redupChekBox = new JCheckBox();
		redupLabel = new JLabel("Reduplication");
		
		buttonGroup1 = new ButtonGroup();
		buttonGroup1.add(stemDnChange);
		buttonGroup1.add(stemDoChange);
		
		lowerPanel = new JPanel();
		lowerPanel.setLayout(new MigLayout());
		lowerPanel.setBorder(BorderFactory.createTitledBorder(""));
		phoneRButton = new JRadioButton("Specify with Phonetic Features");
		alphaRButton = new JRadioButton("Specify with Alphabetic Characters");		

		buttonGroup2 = new ButtonGroup();
		buttonGroup2.add(phoneRButton);
		buttonGroup2.add(alphaRButton);
	}

	private void addComponent() {
		
		addToUpperPanel();
		add(upperPanel, "wrap");
		addToLowerPanel();
		add(lowerPanel);
	}

	private void addToUpperPanel() {
		upperPanel.add(stemDnChange, "wrap");
		upperPanel.add(stemDoChange);
		upperPanel.add(redupChekBox, "gapleft 20");
		upperPanel.add(redupLabel);
	}
	
	private void addToLowerPanel(){
		lowerPanel.add(phoneRButton);
		lowerPanel.add(alphaRButton);
	}

}
